﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Dynamic;
using System.Linq;
using System.Text;
using System.Xml;

namespace Jack.SectionHandler
{
    public class CrawlerConfigurationSectionHandler : IConfigurationSectionHandler
    {
        public object Create(object parent, object configContext, System.Xml.XmlNode section)
        {
            List<dynamic> list = new List<dynamic>();
            if (parent != null)
            {
                list = (List<dynamic>)parent;
            }
            foreach (XmlNode node in section.ChildNodes)
            {
                if (null != node.Attributes)
                {
                    dynamic item = new ExpandoObject();
                    item.WebName = node.Attributes["WebName"].Value;
                    item.WebUrl = node.Attributes["WebUrl"].Value;
                    item.WebGrabbing = node.Attributes["WebGrabbing"].Value;
                    list.Add(item);
                }
            }
            return list;
        }
    }
}
